<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Activities Template</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Activities Template' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Kits</a></li><li><a href="index.html">BasicInformKit</a></li><li><b>Activities Template</b></li></ul></div>
<p class="purpose">To run the necessary rulebooks to carry out an activity.</p>

<ul class="toc"><li><a href="actm.html#SP1">&#167;1. The Activities Stack</a></li><li><a href="actm.html#SP4">&#167;4. Rule Debugging Inhibition</a></li><li><a href="actm.html#SP5">&#167;5. Testing Activities</a></li><li><a href="actm.html#SP6">&#167;6. Emptiness</a></li><li><a href="actm.html#SP7">&#167;7. Process Activity Rulebook</a></li><li><a href="actm.html#SP8">&#167;8. Carrying Out Activities</a></li><li><a href="actm.html#SP9">&#167;9. Begin</a></li><li><a href="actm.html#SP10">&#167;10. For</a></li><li><a href="actm.html#SP11">&#167;11. End</a></li><li><a href="actm.html#SP12">&#167;12. Abandon</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. The Activities Stack.</b>Activities are more like nested function calls than independent processes;
they finish in reverse order of starting, and are placed on a stack. This
needs only very limited size in practice: 20 might seem a bit low, but making
it much higher simply means that oddball bugs in the user's code &mdash; where
activities recursively cause themselves ad infinitum &mdash; will be caught less
efficiently.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">MAX_NESTED_ACTIVITIES</span><span class="plain-syntax"> = </span><span class="constant-syntax">20</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">activities_stack</span><span class="plain-syntax"> --&gt; </span><span class="identifier-syntax">MAX_NESTED_ACTIVITIES</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">activity_parameters_stack</span><span class="plain-syntax"> --&gt; </span><span class="identifier-syntax">MAX_NESTED_ACTIVITIES</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>The <span class="extract"><span class="extract-syntax">Activity_flags</span></span> byte array, indexed by activity number, is a bitmap:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">FUTURE_ACTION_ACTFLAG</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">HIDDEN_IN_RULES_ACTFLAG</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>These variables are not needed by Basic Inform, and are unused in that case,
but are included in <span class="extract"><span class="extract-syntax">BasicInformKit</span></span> anyway in order that the activities code
below can compile in both Basic and regular Inform projects.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">action</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">action_to_be</span><span class="plain-syntax">; </span><span class="comment-syntax">(if the current command line being parsed were accepted)</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Rule Debugging Inhibition.</b>The output from RULES or RULES ALL becomes totally illegible if it is applied
even to the activities printing names of objects, so this is inhibited when
any such activity is running. <span class="extract"><span class="extract-syntax">FixInhibitFlag</span></span> is called each time the stack
changes and ensures that <span class="extract"><span class="extract-syntax">inhibit_flag</span></span> has exactly this meaning.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">inhibit_flag</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved_debug_rules</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">FixInhibitFlag</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax"> </span><span class="identifier-syntax">inhibit_rule_debugging</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax">=0:</span><span class="identifier-syntax">n</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">:</span><span class="identifier-syntax">n</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Activity_flags</span><span class="plain-syntax">-&gt;(</span><span class="identifier-syntax">activities_stack</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">n</span><span class="plain-syntax">)) &amp; </span><span class="identifier-syntax">HIDDEN_IN_RULES_ACTFLAG</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inhibit_rule_debugging</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">inhibit_flag</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">inhibit_rule_debugging</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">saved_debug_rules</span><span class="plain-syntax"> = </span><span class="identifier-syntax">debug_rules</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">debug_rules</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">inhibit_flag</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">inhibit_rule_debugging</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">debug_rules</span><span class="plain-syntax"> = </span><span class="identifier-syntax">saved_debug_rules</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inhibit_flag</span><span class="plain-syntax"> = </span><span class="identifier-syntax">inhibit_rule_debugging</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Testing Activities.</b>The following tests whether a given activity <span class="extract"><span class="extract-syntax">A</span></span> is currently running
whose parameter-object matches description <span class="extract"><span class="extract-syntax">desc</span></span>, where as usual the
description is represented by a routine testing membership, and where
zero <span class="extract"><span class="extract-syntax">desc</span></span> means that any parameter is valid. Alternatively, we can
require a specific parameter value of <span class="extract"><span class="extract-syntax">val</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestActivity</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">desc</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0:</span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">:</span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">activities_stack</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> == </span><span class="identifier-syntax">A</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">desc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">desc</span><span class="plain-syntax">)(</span><span class="identifier-syntax">activity_parameters_stack</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> == </span><span class="identifier-syntax">activity_parameters_stack</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Emptiness.</b>An activity is defined by its three rulebooks: it is empty if they are all
empty.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ActivityEmpty</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Activity_before_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rulebooks_array</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">x</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">EMPTY_RULEBOOK</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Activity_for_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rulebooks_array</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">x</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">EMPTY_RULEBOOK</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Activity_after_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rulebooks_array</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">x</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">EMPTY_RULEBOOK</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RulebookEmpty</span><span class="plain-syntax"> </span><span class="identifier-syntax">rb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rulebooks_array</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">rb</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">EMPTY_RULEBOOK</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Process Activity Rulebook.</b>This is really much like processing any rulebook, except that <span class="extract"><span class="extract-syntax">self</span></span> is
temporarily set to the parameter, and is preserved by the process.
</p>

<p class="commentary">Note that when an activity based on the conjectural "future action" is
being run &mdash; in a few parser-related cases, that is &mdash; the identity of this
action is put temporarily into <span class="extract"><span class="extract-syntax">action</span></span>, and the current value saved while
this takes place. That allows rules in the activity rulebooks to have
preambles based on the current action, and yet be tested against what is not
yet the current action.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ProcessActivityRulebook</span><span class="plain-syntax"> </span><span class="identifier-syntax">rulebook</span><span class="plain-syntax"> </span><span class="identifier-syntax">parameter</span><span class="plain-syntax">  </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">self</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parameter</span><span class="plain-syntax">) </span><span class="identifier-syntax">self</span><span class="plain-syntax"> = </span><span class="identifier-syntax">parameter</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">rulebook</span><span class="plain-syntax">, </span><span class="identifier-syntax">parameter</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">self</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">ProcessActivityRulebookATB</span><span class="plain-syntax"> </span><span class="identifier-syntax">rulebook</span><span class="plain-syntax"> </span><span class="identifier-syntax">parameter</span><span class="plain-syntax">  </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">action</span><span class="plain-syntax">; </span><span class="identifier-syntax">action</span><span class="plain-syntax"> = </span><span class="identifier-syntax">action_to_be</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">self</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parameter</span><span class="plain-syntax">) </span><span class="identifier-syntax">self</span><span class="plain-syntax"> = </span><span class="identifier-syntax">parameter</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">rulebook</span><span class="plain-syntax">, </span><span class="identifier-syntax">parameter</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">self</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">action</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Carrying Out Activities.</b>This is a three-stage process; most activities are run by calling the following
simple routine, but some are run by calling the three subroutines independently.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">CarryOutActivity</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">BeginActivity</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ForActivity</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EndActivity</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Begin.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">BeginActivity</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">MAX_NESTED_ACTIVITIES</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"TooManyActivities"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Too many activities are going on at once."</span><span class="plain-syntax">, </span><span class="identifier-syntax">BasicInformKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">activity_parameters_stack</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">activities_stack</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">++) = </span><span class="identifier-syntax">A</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">FixInhibitFlag</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">MStack_CreateAVVars</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Activity_flags</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">FUTURE_ACTION_ACTFLAG</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ProcessActivityRulebookATB</span><span class="plain-syntax">(</span><span class="identifier-syntax">Activity_before_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ProcessActivityRulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">Activity_before_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. For.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ForActivity</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Activity_flags</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">FUTURE_ACTION_ACTFLAG</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ProcessActivityRulebookATB</span><span class="plain-syntax">(</span><span class="identifier-syntax">Activity_for_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ProcessActivityRulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">Activity_for_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. End.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">EndActivity</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">activities_stack</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">-1) == </span><span class="identifier-syntax">A</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Activity_flags</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">FUTURE_ACTION_ACTFLAG</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ProcessActivityRulebookATB</span><span class="plain-syntax">(</span><span class="identifier-syntax">Activity_after_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ProcessActivityRulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">Activity_after_rulebooks</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">--; </span><span class="identifier-syntax">FixInhibitFlag</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MStack_DestroyAVVars</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"EndedNonRunningActivity"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Tried to end an activity which wasn't going on."</span><span class="plain-syntax">, </span><span class="identifier-syntax">BasicInformKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Abandon.</b>For (very) rare cases where an activity must be abandoned midway; such an
activity must be being run by calling the three stages individually, and
<span class="extract"><span class="extract-syntax">EndActivity</span></span> must not have been called yet.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">AbandonActivity</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">activities_stack</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">-1) == </span><span class="identifier-syntax">A</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">activities_sp</span><span class="plain-syntax">--; </span><span class="identifier-syntax">FixInhibitFlag</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MStack_DestroyAVVars</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"AbandonedNonRunningActivity"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Tried to abandon an activity which wasn't going on."</span><span class="plain-syntax">, </span><span class="identifier-syntax">BasicInformKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="rltm.html">&#10094;</a></li><li class="progresssection"><a href="dftm.html">dftm</a></li><li class="progresssection"><a href="sttm.html">sttm</a></li><li class="progresssection"><a href="uttm.html">uttm</a></li><li class="progresssection"><a href="prgrp.html">prgrp</a></li><li class="progresssection"><a href="mttm.html">mttm</a></li><li class="progresssection"><a href="srtm.html">srtm</a></li><li class="progresssection"><a href="tbtm.html">tbtm</a></li><li class="progresssection"><a href="mstck.html">mstck</a></li><li class="progresssection"><a href="rltm.html">rltm</a></li><li class="progresscurrent">actm</li><li class="progresssection"><a href="prtm.html">prtm</a></li><li class="progresssection"><a href="flx.html">flx</a></li><li class="progresssection"><a href="blckv.html">blckv</a></li><li class="progresssection"><a href="kntm.html">kntm</a></li><li class="progresssection"><a href="txtm.html">txtm</a></li><li class="progresssection"><a href="chtm.html">chtm</a></li><li class="progresssection"><a href="rgtm.html">rgtm</a></li><li class="progresssection"><a href="lstm.html">lstm</a></li><li class="progresssection"><a href="cmtm.html">cmtm</a></li><li class="progresssection"><a href="rkt.html">rkt</a></li><li class="progresssection"><a href="rltns.html">rltns</a></li><li class="progresssection"><a href="prtm2.html">prtm2</a></li><li class="progresssection"><a href="rttm.html">rttm</a></li><li class="progressnext"><a href="prtm.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

